package com.ts.system.impl;

import com.ts.comm.SysResult;
import com.ts.jdbc.SysDB;
import com.ts.system.dao.PublicDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by 马俊鹏 on 2017/5/18.
 */
@Repository
public class PublicDaoImpl implements PublicDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;

	/**
	 * 获得部门树
	 * @return
	 */
	public SysResult getDeptTree() {
		SysResult sysResult=new SysResult();
		String sql="";
		sql="select * from s_department order by 1";
		try {
			List<Map<String, Object>> rows = SysDB.getRows(jdbcTemplate, sql);
			sysResult.setRows(rows);
		} catch (Exception e) {
			sysResult.onSetErrorMsg(e);
		}
		return  sysResult;
	}
}
